﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using RealtyManagementSystem.BLL;

namespace RealtyManagementSystem.Web.Admin
{
    public partial class CreateNewUser : System.Web.UI.Page
    {
        /// <summary>
        /// user type, from query string.
        /// 0 admin
        /// 2 realty manager
        /// </summary>
        private string _usrType = string.Empty;

        private string _roleName = string.Empty;
        public string RoleName
        {
            get { return _roleName; }
        }

        private RoleGroup _userInRoleGroup = new RoleGroup();

        public RoleGroup UserInRoleGroup
        {
            get { return _userInRoleGroup; }
        }


        protected void Page_Load ( object sender, EventArgs e )
        {
            _usrType = Request.QueryString["userType"];

            if (_usrType == "0")//Admin
            {
                _roleName = "超级管理员";
                _userInRoleGroup.Roles = new string[] { "Administrators" };
            }
            else if (_usrType == "2")//Realty Manager
            {
                _roleName = "物业管理员";
                _userInRoleGroup.Roles = new string[] { "RealtyManagers" };
            }
            else if (_usrType == string.Empty)
            {
            }
            else
            {
            }


            if (!IsPostBack)
            {

            }//end NotPostBack
        }


        protected void RegisterUser_CreatedUser ( object sender, EventArgs e )
        {
             Roles.AddUserToRoles(RegisterUser.UserName, _userInRoleGroup.Roles);
        }


        private void CreateUserProfile ( string email, string mobile, string gender, string descr )
        {
            //using (var data = new realtydbEntities())
            //{
            //    var member = (from a in data.aspnet_Membership
            //                 where a.Email == email
            //                 select a).First();
            //    var usrProfile=(from usr in data.)
            //}
        }


    }//end class
}
